import { reqGetCode , reqRegister } from '@/api/register/index'

const state = {
  codeTo:undefined
}
const mutations = {
  GETCODE(state,codeTo){
    state.codeTo = codeTo
  },
  USERREGISTER(state,codeTo){

  }
}
const actions = {
  // 获取验证码
  async getCodeImg({commit}){
    let res = await reqGetCode()
    if(res.code == 200){
      commit('GETCODE',res.data)
      return 'ok'
    }else{
      return Promise.reject(new Error('fail'))
    }
  },
  // 用户注册
  async userRegister({commit},data){
    let res = await reqRegister(data)
    if(res.code == 200){
      console.log(res,'res');
      commit('USERREGISTER',res.data)
    }
  }
}
const getters = {

}

export default{
  state,
  mutations,
  actions,
  getters
}